import { lazy } from 'react';
import Home from '../pages/home';
import Test from '../pages/test';
import Login from '../pages/login';

const basicTable = lazy(() => import('@/pages/table/basic-table'));
const Line = lazy(() => import('@/pages/charts/line'));
const IntervalDemo = lazy(() => import('@/pages/charts/interval'));
const Quill = lazy(() => import('@/pages/editor/quill'));
const NotFound = lazy(() => import('@/pages/401'));

export interface routeItem {
  title?: string;
  exact?: boolean;
  path: string;
  component?: any;
  children?: routeItem[];
  layout?: boolean;
  isLogin?: boolean;
  name?: string;
  icon?: string;
}

const routes: routeItem[] = [
  {
    title: '登录',
    exact: true,
    path: '/login',
    component: Login,
    layout: false,
  },
  {
    exact: true,
    path: '/',
    layout: true,
    component: Home,
    isLogin: true,
    children: [
      {
        title: '首页',
        exact: true,
        path: '/',
        component: Home,
      },
      {
        title: 'test',
        exact: true,
        path: '/test',
        component: Test,
      },
      {
        title: 'table',
        exact: true,
        path: '/table',
        children: [
          {
            title: 'basic-table',
            exact: true,
            path: '/table/basic-table',
            component: basicTable,
          },
        ],
      },
      {
        title: 'echarts',
        exact: true,
        path: '/echarts',
        children: [
          {
            title: 'line',
            exact: true,
            path: '/echarts/line',
            component: Line,
          }, {
            title: 'interval',
            exact: true,
            path: '/echarts/interval',
            component: IntervalDemo,
          },
        ],
      },
      {
        title: 'editor',
        exact: true,
        path: '/editor',
        children: [
          {
            title: 'quill',
            exact: true,
            path: '/editor/quill',
            component: Quill,
          },
        ],
      },
      {
        title: '401',
        exact: true,
        path: '/401',
        component: NotFound,
      },
    ],
  },
];

export default routes;
